package com.dstz.sys.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.core.util.RestTemplateUtil;
import com.dstz.bus.api.remote.RemoteBusinessData;
import com.dstz.org.api.service.GroupService;
import com.dstz.sys.util.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 同 步 所 有 人 员 数 据
 */
@RestController
@RequestMapping("/hrmresource")
public class HrmresourceController {
    //地址
    @Value("${fanwei.url}")
    private String url;
    //同 步 所 有 人 员 数 据
    @Value("${fanwei.AllHrm}")
    private String AllHrm;
    //同 步 所 有 部 门 数 据
    @Value("${fanwei.AllDepartment}")
    private String AllDepartment;
    //全部的岗位信息
    @Value("${fanwei.AllJobTitles}")
    private String AllJobTitles;
    //同 步 所 有 分 部 数 据
    @Value("${fanwei.AllSubCompany}")
    private String AllSubCompany;

    @Autowired
    GroupService groupService;

    @GetMapping("")
    public void getAllHrm(HttpServletRequest request, HttpServletResponse response) throws IOException {
//        String s= HttpUtil.sendPost(url+AllHrm,"");
//        JSONObject jsonObject= JSON.parseObject(s);
//        JSONArray jsonArray=jsonObject.getJSONArray("msg");
//        jsonArray.forEach(j->{
//            JSONObject jsonObjec=JSON.parseObject(String.valueOf(j));
//            String showOrderOfTree=jsonObjec.getString("showOrderOfTree");
//        });
        String url = "http://localhost:18084/org/group/save";
        RemoteBusinessData<JSONObject> remoteBusinessData = new RemoteBusinessData<>();
        JSONObject insetJosn=new JSONObject();
        insetJosn.put("code","12345");
        insetJosn.put("name","测试部");
        insetJosn.put("parentId","410054574497333249");
        insetJosn.put("parentName","信阳分公司");
        insetJosn.put("sn",1);
        remoteBusinessData.setData(insetJosn);
        ResultMsg<JSONObject> resp = RestTemplateUtil.post(url, remoteBusinessData, ResultMsg.class);

        System.out.println(resp);
    }


}
